<template>
    <input type="text" v-model="val">
    <button @click="handleAdd">点击提交</button>
</template>
<script setup>
import { ref, defineEmits } from "vue"
let val = ref('')
//获取一个emit对象
let emit = defineEmits(['add'])

let handleAdd = () => {
    emit('add', val.value)
    val.value = ''
}

</script>